<% if session[:user_id] %>
	<h1>Procesadores disponibles</h1>

	<table border=1>
		<tr>
		  <th>Título</th>
		  <th>Descripcion</th>
		  <th>Nº núcleos</th>
		  <th>Velocidad del reloj (MHz)</th>
		  <th>Niveles de caché</th>
		  <th>Tamaño caché</th>
		  <th>URL</th>
		  <th>Precio</th>
		  <th></th>
		  <th></th>
		  <th></th>
		</tr>

	<% @processors.each do |processor| %>
		<tr>
		  <td><%= processor.title %></td>
		  <td><%= processor.description %></td>
		  <td class="center"><%= processor.cores %></td>
		  <td class="center"><%= processor.clockspeed %></td>
		  <td class="center"><%= processor.cachelevel %></td>
		  <td class="center"><%= processor.cachecapacity %></td>
		  <td><%= link_to processor.product_url, processor.product_url, :target => '_blank' %></td>
		  <td class="center"><%= processor.price %></td>
		  <td class="links"><%= link_to 'Mostrar', processor %></td>
		  <td class="links"><%= link_to 'Editar', edit_processor_path(processor) %></td>
		  <td class="links"><%= link_to 'Eliminar', processor, method: :delete, data: { confirm: '¿Está seguro?' } %></td>
		</tr>
	<% end %>
	</table>


	<br />

	<%= link_to 'Nuevo procesador', new_processor_path %>
<% else %>
	<% if notice %>
	<p id="notice"><%= notice %></p>
	<% end %>

	<h1>Catalogo de procesadores</h1>

	<% @processors.each do |processor| %>
		<div class="entry">
			<h3><%= processor.title %></h3>
			<%= sanitize(processor.description) %>
			<div class="price_line">
				<span class="price"><%= number_to_currency(processor.price) %></span>
				<% prod = Product.find(:first, :conditions => ["heir_id = ? and heir_type = ?",processor.id, 'Processor']) %>
				<%= button_to 'Añadir a la configuracion', line_products_path(product_id: prod.id) %>
			</div>
		</div>
	<% end %>
<% end %>


